package moonstruckdrops.page;

import java.util.Date;

import moonstruckdrops.dao.EntryDao;
import moonstruckdrops.dto.EntryDto;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.PropertyModel;

import com.google.appengine.api.datastore.Text;

public class NewEntryPage extends WebPage{

	String inputTitleText="";
	String inputContentText="";
	
	public NewEntryPage(){
		final TextField<String> Title =new TextField<String>("EntryTitle",new PropertyModel<String>(this,"inputTitleText"));
		final TextArea<String> Content = new TextArea<String>("EntryContent",new PropertyModel<String>(this,"inputContentText"));
		Form<Void> EntryForm =new Form<Void>("EntryForm"){
			private static final long serialVersionUID = 1L;
			public void onSubmit(){
				EntryDto NewEntry = new EntryDto(new Date((System.currentTimeMillis()+32400000)),Title.getInput(),new Text(Content.getInput()));
				EntryDao Dao = new EntryDao();
				Dao.NewEntrySave(NewEntry);
				setResponsePage(BlogMainPage.class);
			}
		};
		add(EntryForm);
		EntryForm.add(Title);
		EntryForm.add(Content);
	}
}